#include "dna_info_holder.h"
#include "dna_info.h"

namespace design_patterns
{

DnaInfoHolder::DnaInfoHolder(
    std::map<std::string, std::string>&& raw_records): 
    raw_records(raw_records)
{}

DnaInfoHolder::~DnaInfoHolder()
{}

DnaInfo& DnaInfoHolder::GetDnaInfo(std::string const& dna_header)
{
  auto it = processed_entries.find(dna_header);
  if (it == processed_entries.end())
  {
    auto emplace_result = processed_entries.emplace(dna_header, 
                                                    raw_records[dna_header]);
    it = emplace_result.first;
    it->second.DoSomeExpensiveWork();
  }

  return it->second;
}

} // namespace design_patterns